<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>046-隔行变色.html</title>
</head>
<body>
	<ul id="list">
		<li>1</li>
		<li>2</li>
		<li>3</li>
		<li>4</li>
		<li>5</li>
		<li>6</li>
		<li>7</li>
		<li>8</li>
		<li>9</li>
	</ul>
</body>
<script>
	var aLi = document.getElementsByTagName('li');
	for (var i = 0; i< aLi.length;i++){
		// aLi[i].style.background = "red";
		if(i%2 == 0){
			aLi[i].style.background = "red";

		}else{
			aLi[i].style.background = "yellow";
		}
	}
</script>
</html>